package o;

import android.os.Looper;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;

public final class fjz {

    static class b<TResult> implements fjr, fjp<TResult> {
        public final CountDownLatch ˊ = new CountDownLatch(1);

        public final void ˎ(Exception exception) {
            this.ˊ.countDown();
        }

        public final void ˎ(TResult tResult) {
            this.ˊ.countDown();
        }
    }

    public static void ˎ(String str) {
        if (Looper.myLooper() == Looper.getMainLooper()) {
            throw new IllegalStateException(str);
        }
    }

    public static <TResult> TResult ˏ(fjo<TResult> o_fjo_TResult) throws ExecutionException {
        if (o_fjo_TResult.ˊ()) {
            return o_fjo_TResult.ॱ();
        }
        throw new ExecutionException(o_fjo_TResult.ˋ());
    }

    public final <TResult> fjo<TResult> ˏ(Executor executor, final Callable<TResult> callable) {
        final fjx o_fjx = new fjx();
        try {
            executor.execute(new Runnable(this) {
                final /* synthetic */ fjz ˏ;

                public final void run() {
                    try {
                        o_fjx.ॱ(callable.call());
                    } catch (Exception e) {
                        o_fjx.ॱ(e);
                    }
                }
            });
        } catch (Exception e) {
            o_fjx.ॱ(e);
        }
        return o_fjx.ॱ();
    }
}
